package research.ui.editors.tableeditors.testtype;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import research.core.Activator;
import research.domain.TestParameter;
import research.ui.editors.tableeditors.EntityLabelProvider;

public class TestTypeLabelProvider 
	extends EntityLabelProvider
	implements ITableLabelProvider {
	
	public static final Image CHECKED_IMAGE = Activator.getImageDescriptor("icons/checked.gif").createImage();
	public static final Image UNCHECKED_IMAGE = Activator.getImageDescriptor("icons/unchecked.gif").createImage();

	private Image getImage(boolean isSelected) {
		return isSelected ? CHECKED_IMAGE : UNCHECKED_IMAGE;
	}

	@Override
	public String getColumnText(Object element, int columnIndex) {
		String result = "";
		TestParameter par = (TestParameter) element;
		switch (columnIndex) {
			case 0:
				result = render(par.getName());
				break;
			case 1:
				result = render(par.getUnits());
				break;
			case 2:
				break;
			case 3:
				result = render(par.getDescription());
				break;
			default :
				break; 	
		}
		return result;
	}
	
	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		return (columnIndex == 2) ? getImage(((TestParameter) element).isReported()) :	null;
	}
}
